
import { _decorator, Component, Node, Mesh, utils } from 'cc';
import { ParticleItem } from './ParticleItem';
const { ccclass, property } = _decorator;

@ccclass('ChongJiBo')
export class ChongJiBo extends ParticleItem {

    protected addPositions(r: number = 0.5) {
        this.meshData.positions.push(
            -r, 0, r,
            -r, 0, -r,
            r, 0, -r,
            r, 0, r,
        );
    }

    protected particleCount: number = 48;
    protected createAnim() {
        let Pos = [0, 0, 0, 0];
        let SO = [0, 0, 1, 0];
        let Time = [0.3, 0.5, 0.5, 0];
        let Ease = [0, 0, 0, 0];
        let cr = 1.5;
        let s0 = 1;
        let stepRadian = 0.523;
        let index = 0;
        for (let i = 0; i < 12; ++i) {
            let radian = stepRadian * i;
            let x = cr * Math.cos(radian);
            let y = cr * Math.sin(radian);
            for (let j = 0; j < 4; ++j) {
                Pos[2] = x + (Math.random() - 0.5) * 0.5;
                Pos[3] = y + (Math.random() - 0.5) * 0.5;
                SO[1] = s0 + (Math.random() - 0.5) * 0.2;
                this.cacheParticleAnim(index++, Pos, SO, Time, Ease);
            }
        }
    }

}
